<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>产品管理管理</title>
    <meta name="decorator" content="default"/>
</head>
<body>
<div class="main-content">
    <tags:breadcrumb menuId="产品列表"/>
    <div class="page-content">
        <table id="contentTable" class="table table-striped table-bordered table-hover">
            <thead>
            <tr>
                <th>缩略图</th>
                <th>中文名称</th>
                <th>英文名称</th>
                <th>价格</th>
                <th>开盘日期</th>
                <th>户型</th>
                <shiro:hasPermission name="cms:product:edit">
                    <th>操作</th>
                </shiro:hasPermission></tr>
            </thead>
            <tbody>
            <c:forEach items="${page.list}" var="product">
                <tr>
                    <td>
                        <c:choose>
                            <c:when test="${!empty product.miniLogo}">
                                <img src="${product.miniLogo}" style="width: 100px;height: 100px;"/>
                            </c:when>
                            <c:otherwise>
                                <img src="${ctxStatic}/images/nopic.gif" style="width: 100px;height: 100px;"/>
                            </c:otherwise>
                        </c:choose>
                    </td>
                    <td><a href="${ctx}/cms/product/form?id=${product.id}">${product.name}</a></td>
                    <td>${product.enname}</td>
                    <td>${product.price}</td>
                    <td>${product.openDate}</td>
                    <td>${product.houseStyle}</td>
                    <shiro:hasPermission name="cms:product:edit">
                        <td>
                            <a href="${ctx}/cms/product/form?id=${product.id}">修改</a>
                            <a href="javascript:;"
                               onclick="deleteMsg('确认要删除该文本消息模板吗？','${ctx}/cms/product/delete?id=${product.id}',this);">删除</a>
                        </td>
                    </shiro:hasPermission>
                </tr>
            </c:forEach>
            </tbody>
        </table>
        <div class="pagination">${page}</div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {

    });

    //删除
    function deleteMsg(msg, href, tr) {
        bootbox.confirm(msg, function (obj) {
            if (obj) {
                $.post(href, function (data) {
                    if (data.success) {
                        showNote("success", function () {
                            $(tr).parent().parent().remove();
                        }, data.msg, "center");
                    } else {
                        showNote("error", function () {
                            return false;
                        }, data.msg);
                    }
                });
            }
        });
    }

    function page(n, s) {
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#searchForm").submit();
        return false;
    }
</script>
</body>
</html>
